// /api/diaryItem
let btn_n = document.querySelector('.btn_n')
let year = document.querySelector('.ss') //年
let month = document.querySelector('.title-date span') // 月
let date = document.querySelector('.title-date b') // 日

console.log(year);

btn_n.onclick = function () {
    var btn_n = document.body.scrollTop || document.documentElement.scrollTop
    scrollBy(0, -btn_n);
}

let data_d = new Date()

var year1 = data_d.getFullYear(), //年

    month1 = data_d.getMonth() + 1, //月

    date1 = data_d.getDate(), //日

    h = data_d.getHours(),

    m = data_d.getMinutes(),

    s = data_d.getSeconds()

day1 = data_d.getDay(),
    week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]

console.log(year1, month1, date1, day1);

myDiary()

function data_data() {
    let html = ''

    html = `
    <div class="sidebar-item title-date">
    ${month1}/${date1}
    <span>/${year1}</span>
    <b>${week[day1]}</b>
     </div>
    `
    year.innerHTML = html
}
data_data()

async function myDiary() {
    let res = await axios({
        method: 'GET',
        url: '/api/diaryItem/homepage',
        params: {
            limit: 1,
            offset: 0,
        }
    })
    // console.log(res);
    let data = res.data.data
    console.log(data);
    let diary = document.querySelector('.diary')
    let html = ''
    data.forEach(item => {
        html += `
       <div class="body body-no-icon">
       <div class="title">
         ${h} : ${m} am <a class="book" href="#">过日子</a>
      </div>
      <pre class="content">
      ${item.content}
<img class="emojione" alt="😝" src=" "><img class="emojione" alt="😝" src=" ">
</pre>
      <div class="bottom">
          <a class="a" href="#">回复</a>
      </div>
  </div>
      `
    })

    diary.innerHTML = html

    let aa = document.querySelectorAll('.a')
    // console.log(aa);
    aa.forEach((item) => {
        item.onclick = function () {

            console.log(1);

            window.location.href = '../../html/ys/reply.html'

        }
    })

}

myDiary()